package main

import (
	"github.com/kataras/iris/v12"
	log "github.com/sirupsen/logrus"
)

type ValidateResponse struct {
	ServerVersion         string `json:"serverVersion"`
	ServerProtocolVersion string `json:"serverProtocolVersion"`
	ServerGUID            string `json:"serverGuid"`
	GroupType             string `json:"groupType"`
	StatusCode            string `json:"statusCode"`
	Company               string `json:"company"`
	CanGetLease           bool   `json:"canGetLease"`
	LicenseType           int    `json:"licenseType"`
	EvaluationLicense     bool   `json:"evaluationLicense"`
	SeatPoolType          string `json:"seatPoolType"`
}

func ValidateLicense(context iris.Context) {
	username := context.URLParam("username")
	log.WithFields(log.Fields{
		"platform": "jrebel",
		"username": username,
	}).Info("JRebel 验证许可")
	result := ValidateResponse{
		ServerVersion:         "3.2.4",
		ServerProtocolVersion: "1.1",
		ServerGUID:            serverGUID,
		GroupType:             "managed",
		StatusCode:            "SUCCESS",
		Company:               username,
		CanGetLease:           true,
		LicenseType:           1,
		EvaluationLicense:     false,
		SeatPoolType:          "standalone",
	}
	context.JSON(result)
}
